package com.shujia.mr.youhua;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class WeatherReducer extends Reducer<Text, LongWritable, Text, LongWritable> {
    @Override
    protected void reduce(Text key, Iterable<LongWritable> values, Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        long maxTemp = 0L;

        for (LongWritable value : values) {
            long tmp = value.get();
            if (tmp > maxTemp) {
                maxTemp = tmp;
            }
        }

        context.write(new Text(key), new LongWritable(maxTemp));
    }
}
